{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a634365e",
   "metadata": {},
   "source": [
    "# Tencent COS Directory\n",
    "\n",
    ">[Tencent Cloud Object Storage (COS)](https://www.tencentcloud.com/products/cos) is a distributed \n",
    "> storage service that enables you to store any amount of data from anywhere via HTTP/HTTPS protocols. \n",
    "> `COS` has no restrictions on data structure or format. It also has no bucket size limit and \n",
    "> partition management, making it suitable for virtually any use case, such as data delivery, \n",
    "> data processing, and data lakes. `COS` provides a web-based console, multi-language SDKs and APIs, \n",
    "> command line tool, and graphical tools. It works well with Amazon S3 APIs, allowing you to quickly \n",
    "> access community tools and plugins.\n",
    "\n",
    "\n",
    "This covers how to load document objects from a `Tencent COS Directory`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85e97267",
   "metadata": {},
   "outputs": [],
   "source": [
    "%pip install --upgrade --quiet  cos-python-sdk-v5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2f0cd6a5",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from langchain_community.document_loaders import TencentCOSDirectoryLoader\n",
    "from qcloud_cos import CosConfig"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "321cc7f1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "conf = CosConfig(\n",
    "    Region=\"your cos region\",\n",
    "    SecretId=\"your cos secret_id\",\n",
    "    SecretKey=\"your cos secret_key\",\n",
    ")\n",
    "loader = TencentCOSDirectoryLoader(conf=conf, bucket=\"you_cos_bucket\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4c50d2c7",
   "metadata": {},
   "outputs": [],
   "source": [
    "loader.load()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0690c40a",
   "metadata": {},
   "source": [
    "## Specifying a prefix\n",
    "You can also specify a prefix for more finegrained control over what files to load."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "72d44781",
   "metadata": {},
   "outputs": [],
   "source": [
    "loader = TencentCOSDirectoryLoader(conf=conf, bucket=\"you_cos_bucket\", prefix=\"fake\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2d3c32db",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "loader.load()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
